from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
# 打开浏览器
driver = webdriver.Chrome()
driver.get('https://book.qq.com/')
sleep(2)
# 窗口最大化
driver.maximize_window()
# 强制等待 点击登录
sleep(10)
# 进入frame框架
f = driver.find_element(By.NAME, 'ui_ywlogin')
driver.switch_to.frame(f)
# 点击账号登录
driver.find_element(By.XPATH, '/html/body/div/div[1]/ul/li[1]').click()
sleep(2)
# 输入账号
driver.find_element(By.ID, 'username').send_keys('15985645480')
sleep(2)
# 输入密码
driver.find_element(By.ID, 'password').send_keys('12345678Aa')
sleep(2)
# 点击用户协议
driver.find_element(By.XPATH, '//*[@id="j-loginInputMode"]/div[3]/div[1]/p[2]/label').click()
sleep(2)
# 点击登录
driver.find_element(By.CLASS_NAME, 'red-btn.go-login.btnLogin.login-button').click()
sleep(10)
